package com.lm.redis.controller;

import com.lm.redis.service.HotCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

@RestController
public class HotCommentController {

    @Autowired
    private HotCommentService hotCommentService;

    // 用户点赞评论接口
    @PostMapping("/like/{commentId}")
    public String likeComment(@PathVariable String commentId) {
        hotCommentService.addCommentLike(commentId);
        return "Comment liked!";
    }

    // 获取本周热门评论接口
    @GetMapping("/hot-comments/{topN}")
    public Set<String> getHotComments(@PathVariable int topN) {
        return hotCommentService.getWeeklyHotComments(topN);
    }
}